package com.fyl.pattern.visitor;

import java.util.ArrayList;
import java.util.List;

/**
 * 对象结构类
 */
public class Home {
    //声明一个集合，用来存储元素
    private List<Animal> animals = new ArrayList<Animal>();

    public void addAnimal(Animal animal) {
        animals.add(animal);
    }

    public void action(Person person) {
        for (Animal animal : animals) {
            animal.accept(person);
        }
    }
}
